package com.netcracker.util.dao.closer;

import com.netcracker.db.exception.DBException;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public abstract class DAOCloseHelper {
    protected void closeResultSet(ResultSet resultSet) throws DBException
    {
        if (resultSet!=null)
        {
            try {
                resultSet.close();
            } catch (SQLException e) {
                throw new DBException(e.getMessage(), e);
            }
        }
    }

    protected void closeStatement(PreparedStatement statement) throws DBException
    {
        if (statement!=null)
        {
            try {
                statement.close();
            } catch (SQLException e) {
                throw new DBException(e.getMessage(), e);
            }
        }
    }
}
